package com.xmy.cultivate.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xmy.cultivate.entity.SystemOperationLog;
import com.xmy.cultivate.service.ISystemOperationLogService;
import com.xmy.cultivate.util.Code;
import com.xmy.cultivate.util.PageResult;
import com.xmy.cultivate.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 操作日志 前端控制器
 * </p>
 *
 * @author hpiggy
 * @since 2025-08-27
 */
@RestController
@RequestMapping("/api/systemOperationLog")
public class SystemOperationLogController extends BaseController {

    @Autowired
    private ISystemOperationLogService iSystemOperationLogService;

    @GetMapping("/pageList")
    public Result pageList(
            @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
            @RequestParam(value = "yearPart", required = false) Integer yearPart,
            @RequestParam(value = "quarterNum", required = false) Integer quarterNum,
            @RequestParam(value = "startDate", required = false) String startDate,
            @RequestParam(value = "endDate", required = false) String endDate,
            @RequestParam(value = "teacherName", required = false) String teacherName,
            @RequestParam(value = "operationType", required = false) Integer operationType
    ) {
        IPage<SystemOperationLog> page = new Page<>(pageNum, pageSize);
        page = iSystemOperationLogService.pageList(page, yearPart, quarterNum, startDate, endDate, teacherName,operationType);
        return new Result(Code.GET_OK, new PageResult(page.getRecords(), page.getTotal(), page.getPages()), Code.GET_OK_MSG);
    }
}
